package com.yh.csx.bsf.demo.db;

import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder;
import com.yh.csx.bsf.core.util.PropertyUtils;
import com.yh.csx.bsf.core.util.ReflectionUtils;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import javax.sql.DataSource;
import java.util.Properties;

@Configuration
public class DbConfig {
//    @Bean("data1")
//    @ConfigurationProperties("spring.datasource.data1")
//    @Primary
//    public DataSource data1DataSource(){
//        return DataSourceBuilder.create().type(ReflectionUtils.classForName(PropertyUtils.getPropertyCache("spring.datasource.data1.type",""))).build();
//    }
//    @Bean("data2")
//    @ConfigurationProperties("spring.datasource.data2")
//    public DataSource data2DataSource(){
//        return DataSourceBuilder.create().type(ReflectionUtils.classForName(PropertyUtils.getPropertyCache("spring.datasource.data2.type",""))).build();
//    }

}
